﻿using Crux.Core.Validations;

namespace System;
/// <summary>
/// 
/// </summary>
public static class Verify
{
    /// <summary>
    /// 
    /// </summary>
    /// <param name="condition"></param>
    /// <param name="message"></param>
    /// <exception cref="InvalidOperationException"></exception>
    [DebuggerStepThrough]
    public static void Operation(bool condition, string message)
    {
        if (!condition)
        {
            throw new InvalidOperationException(message);
        }
    }
    /// <summary>
    /// 
    /// </summary>
    /// <param name="condition"></param>
    /// <param name="unformattedMessage"></param>
    /// <param name="arg1"></param>
    /// <exception cref="InvalidOperationException"></exception>
    [DebuggerStepThrough]
    public static void Operation(bool condition, string unformattedMessage, object arg1)
    {
        if (!condition)
        {
            throw new InvalidOperationException(PrivateErrorHelpers.Format(unformattedMessage, arg1));
        }
    }
    /// <summary>
    /// 
    /// </summary>
    /// <param name="condition"></param>
    /// <param name="unformattedMessage"></param>
    /// <param name="arg1"></param>
    /// <param name="arg2"></param>
    [DebuggerStepThrough]
    public static void Operation(bool condition, string unformattedMessage, object arg1, object arg2)
    {
        if (!condition)
        {
            throw new InvalidOperationException(PrivateErrorHelpers.Format(unformattedMessage, arg1, arg2));
        }
    }
    /// <summary>
    /// 
    /// </summary>
    /// <param name="condition"></param>
    /// <param name="unformattedMessage"></param>
    /// <param name="args"></param>
    [DebuggerStepThrough]
    public static void Operation(bool condition, string unformattedMessage, params object[] args)
    {
        if (!condition)
        {
            throw new InvalidOperationException(PrivateErrorHelpers.Format(unformattedMessage, args));
        }
    }
    /// <summary>
    /// 
    /// </summary>
    /// <param name="message"></param>
    /// <param name="args"></param>
    /// <returns></returns>
    [DebuggerStepThrough]
    public static Exception FailOperation(string message, params object[] args) => throw new InvalidOperationException(PrivateErrorHelpers.Format(message, args));
    /// <summary>
    /// 
    /// </summary>
    /// <param name="condition"></param>
    /// <param name="message"></param>
    [DebuggerStepThrough]
    public static void NotDisposed(bool condition, string message)
    {
        if (!condition)
        {
            throw new ObjectDisposedException(message);
        }
    }
}
